// pages/my/myInfo.js
//var card = require("../card/card.js")
const config = require('../../config.js');
var touchMove = require('../card/touchMove.js');
Page({
  data:{
    currentGesture: 0,
    lastX: 0,
    lastY: 0,
    winHeight:0,
    scrollTop: 0,
    animation: '',
    transform: '',
    hide:''
  },

  phoneCall:function(event){
      console.log(event)
      var telno = event.currentTarget.dataset.telno
      wx.makePhoneCall({
        phoneNumber: telno
        
      })
  },

  handleImg: function(event){
    console.log(event)   
    var _url = event.target.dataset.url
    wx.previewImage({
      // current: 'String', // 当前显示图片的链接，不填则默认为 urls 的第一张
      urls: [_url],
      success: function(res){
        // success
      },
      fail: function() {
        // fail
      },
      complete: function() {
        // complete
      }
    })
  },
  onLoad:function(options){
    // 页面初始化 options为页面跳转所带来的参数
    //  touchMove.handletouchmove();


  },

  scrollTopFun: function(e){
    var node = this
    wx.getSystemInfo( {  
  
      success: function( res ) {  
        node.setData( {  
          winHeight: res.windowHeight  
        });  
      }  
  
    });  

    this.animation = wx.createAnimation({
      duration: 500,
        timingFunction: 'linear',
    })

  
    console.log(e.detail);  
    if(e.detail.scrollTop < 300){//触发gotop的显示条件  

        this.animation.translateY(e.detail.scrollTop).step(10)
        this.setData({
       animation:this.animation.export(), 
      
    })
    
    var that = this
    if(!(this.data.hide=='display: none;')){
      setTimeout(function (){
       that.setData({scrollTop:0}
     )}, 100)
    }
     
    
     

    }else{  
      this.setData({
          hide: 'display: none;'
        })
      this.animation.translateY(-(this.data.winHeight)).step(10)
        this.setData({
       animation:this.animation.export(), 
       transform:'transition-duration: 1s; transform: translateY('+(-20)+'px)',
      scrollTop:0
    })
    }  
    
   
  },  
  handletouchmove: function (event) {
    touchMove.handletouchmove(event, this)
  },
    // 向上滑动事件
  pullUp: function(ty, num){
    // this.setData({
    //   scrollTop: wx.getSystemInfoSync().windowHeight
    // })
   
    // var  wHeight 
    // wx.getSystemInfo({
    //   success: function(res) {
    //     wHeight = res.windowHeight
    //   }
    // })

    // console.log("向上滑动事件"+ty)
    // this.setData({class:'show'})

    // console.log(num)
    // console.log(num/(wHeight))
    // num = num - ty;
    // if(num/(wHeight) > 0.6){   
    //   console.log(1)
    // //  this.setData({  
    // //      transform: 'transform: translateY(0px)'  
    // //  }) 
    // //  this.setData({
    // //         cardDivClass: 'hide'
    // //  }) 
     
    // }else{  
    //   console.log(2)
    //     // this.setData({  
    //     //     transformcardDiv: 'transform: translateY(20px)' 
    //     // })
    //     // this.setData({
    //     //     class: !'show'
    //     // })   
    // }  
    
  },
  // 下拉事件
  dropDown: function(ty){
    console.log("下拉事件"+Math.abs(ty))
    console.log("下拉事件")
    if(Math.abs(ty)>30){
      wx.showToast({title: '收藏成功',
  icon: 'success',
  duration: 2000})
    }
  },

  mytap: function () {
    console.log('9999999999999999999');
    this.animation.translateY((0)).step(10)
        this.setData({
       transform: 'transition-duration: 1s; transform: translateY(600px)',
      scrollTop: 0
     
    });
    var that = this
    setTimeout(function (){
      that.setData({hide: 'display: block', animation:that.animation.export() })
    }, 600)

  },

  onReady:function(){
    // 页面渲染完成
  },
  onShow:function(){
    // 页面显示
  },
  onHide:function(){
    // 页面隐藏
  },
  onUnload:function(){
    // 页面关闭
  }
})